"""

文件操作

"""
# f=open("da.txt","r",encoding="UTF-8")
"""读取指定字节"""
# print(f.read(10))
# print(f.read())
# """有参数为指定字节 无参数为全部内容"""
# print(f.readline())
# print(f.readlines())
# print(f.readlines())
"""遍历
for line in open("da.txt","r",encoding="UTF-8"):
    print(line)
"""
"""自动将文件关闭
with open("da.txt","r",encoding="UTF-8") as f:
    for line in f:
        print(line)
"""

"""
文件的写入
"""
# 文件不存在会自动创建
# f=open("dada.txt","w",encoding="UTF-8")
# f.write("hello world!!")
# f.close()
# close内置flush功能
# 当文件被关闭后或者文件被flush时 内容才会从内存中写入文件中
# f=open("dada.txt","a",encoding="UTF-8")
# f.write("\nhehhhhh")
# f.flush()

"""
练习题
"""
with open("da.txt","r",encoding="UTF-8") as f:
    c=open("bill.txt.bak","w",encoding="UTF-8")
    for line in f:
        line=line.strip()
        if line.split(",")[-1]=="测试" :
            continue
        else:
            c.write(line)
            c.write("\n")





